using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using System.Diagnostics;

namespace The_LarX
{
    public class PhysicAnimatedSprite : AnimatedSprite2D
    {
        #region Variables
        /// <summary>
        /// The PhysicBody
        /// </summary>
        public PhysicBody Body;

        #endregion

        #region Constructors

        /// <summary>
        /// Constructor 1 - Starts a PhysicAnimatedSPrite
        /// </summary>
        /// <param name="NumFrames">The number of Frames that the texture Has</param>
        /// <param name="MsBetweenFrames">The time that it should take to go to the next frame</param>
        /// <param name="TextureName">The texture's place</param>
        /// <param name="Position">The Initial Position</param>
        public PhysicAnimatedSprite(int NumFrames, int MsBetweenFrames, string TextureName, Vector2 Position)
            : base(NumFrames, MsBetweenFrames, TextureName, Position) 
        {
            Body = new PhysicBody(new Rectangle((int)Position.X, (int)Position.Y, Width, Texture.Height));
            Body.Position = Position;
            Body.Parent = this;
        }
        /// <summary>
        /// Constructor 2 - Used For Serializing
        /// </summary>
        public PhysicAnimatedSprite() { }

        #endregion

        #region Update and Draw

        public override void Update()
        {
            base.Update();                        
                     
            Body.Update();
            Position = Body.Position;            
            Body.Rectangle = this.SizeRectangle;
        }

        public override void Draw()
        {
            base.Draw();
        }

        #endregion

        #region Serialize Data

        public override void SerializeData(SerializeData Data)
        {
            base.SerializeData(Data);

            Body.SerializeData(Data);
        }

        public override void DeserializeData(SerializeData Data)
        {
            base.DeserializeData(Data);

            Body = new PhysicBody(this.SizeRectangle);
            Body.DeserializeData(Data);
        }

        #endregion
    }
}
